<?php
/*
 * @Author: your name
 * @Date: 2020-12-23 12:01:16
 * @LastEditTime: 2020-12-28 10:22:28
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /special/application/common/service/platform_manage/ServerMiddlewareService.php
 */
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2020/1/13
 * Time: 10:42
 */

namespace app\common\service\platform_manage;


use think\Db;

class ServerMiddlewareService
{
    /**
     * @name 中间键管理列表
     * @param $params
     * @author wx
     * @date 2020/1/13 10:50
     */
    public function list($params)
    {
        $db = Db::name('server_middleware');

        if(isset($params['type']) && !empty($params['type'])){
            $db->where('type', $params['type']);
        }
        if(isset($params['version']) && !empty($params['version'])){
            $db->where('version', 'like','%'.$params['version'].'%');
        }
        if(isset($params['name']) && !empty($params['name'])){
            $db->where('name', 'like','%'.$params['name'].'%');
        }
        if(isset($params['ip']) && !empty($params['ip'])){
            $db->where('ip', 'like','%'.$params['ip'].'%');
        }

        $list = $db->order('id desc')->paginate()->toArray();

        return $list;
    }


    /**
     * @name 查找数据
     * @param $condition
     * @author wx
     * @date 2020/1/13 13:45
     */
    public function findData($condition)
    {
        return Db::name('server_middleware')->where($condition)->find();
    }

    public function modify($condition, $UpdateData)
    {
        return Db::name('server_middleware')->where($condition)->update($UpdateData);
    }

    public function add($addData)
    {
        return Db::name('server_middleware')->insert($addData);
    }
}